package com.woniu.product.controller;

import com.woniu.common.util.ResponseData;
import com.woniu.product.pojo.TProductSpu;
import com.woniu.product.service.TProductSpuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 杜梅杰
 * @Description
 * @Date 2024/5/20 22:48
 */
@RestController
public class SpuController {
    @Autowired
    private TProductSpuService spuService;

    /**
     * 根据种类,品牌查下面商品
     */
    @PostMapping("/querySpus")
    public ResponseData<TProductSpu> querySpus(String sortId,String brandId) {
        List<TProductSpu> spuList = spuService.lambdaQuery()
                .eq(TProductSpu::getSortId, sortId)
                .eq(TProductSpu::getBrandId, brandId)
                .eq(TProductSpu::getState, 1).list();
        return new ResponseData<>().ok(spuList);
    }

    /**
     * 查询商品的详细信息
     */
    @PostMapping("/querySpu")
    public TProductSpu querySpu(Long spuId) {
        return spuService.getById(spuId);
    }


}
